package com.example.mobile2021606127cxz0323homework;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity3 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        initView();
    }

    public void initView() {
        EditText edtTxt_username = findViewById(R.id.edtTxt_main_username);
        EditText edtTxt_psw = findViewById(R.id.edtTxt_main_psw);
        EditText edtTxt_newagain = findViewById(R.id.edtTxt_main_newagain);
        Button btn_zhuce = findViewById(R.id.btn_main_zhuce);
        btn_zhuce.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String text = edtTxt_username.getText().toString().trim();
                String text2 = edtTxt_psw.getText().toString().trim();
                String text3 = edtTxt_newagain.getText().toString().trim();
                if (text.length() == 0 || text2.length() == 0 || text3.length()==0) {
                    Toast.makeText(MainActivity3.this, "用户名和密码不能为空", Toast.LENGTH_SHORT).show();
                } else if (6 > text.length()) {
                    Toast.makeText(MainActivity3.this, "用户名长度应在6-10字之间", Toast.LENGTH_SHORT).show();
                } else if (text.length() > 10) {
                    Toast.makeText(MainActivity3.this, "用户名长度应在6-10字之间", Toast.LENGTH_SHORT).show();
                } else if (edtTxt_psw.getText().toString().trim().equals(edtTxt_newagain.getText().toString().trim())){
                    Toast.makeText(MainActivity3.this, "注册成功", Toast.LENGTH_SHORT).show();
//                    MainActivity3.this.finish();
                }else {
                    Toast.makeText(MainActivity3.this,"两次输入的密码不一致，请重新检查",Toast.LENGTH_SHORT).show();

                }

            }
        });
    }

}